/* eslint-disable indent */
'use strict'
const path = require('path')

function assetsPath (_path) {
  const assetsSubDirectory = 'static'
  return path.posix.join(assetsSubDirectory, _path)
}

function resolve (dir) {
  return path.join(__dirname, '..', dir)
}

module.exports = {
  baseUrl: '',
  configureWebpack: config => {
  },
  chainWebpack: config => {
    config.module.rule('svg').uses.clear()
    config.module.rule('images').uses.clear()
    config.module.rule('svgsprint')
      .test(/\.svg$/)
      .include
        .add(resolve('src/icons'))
        .end()
      .use('svg-sprite-loader')
        .loader('svg-sprite-loader')
        .options({ symbolId: 'icon-[name]' })
    const svgUrl = config.module.rule('svgurl')
    svgUrl.test(/\.(png|jpe?g|gif|svg)(\?.*)?$/)
      .exclude
        .add(resolve('src/icons'))
        .end()
      .use('url-loader')
      .loader('url-loader')
      .options({
        limit: 10000,
        name: assetsPath('img/[name].[hash:7].[ext]')
      })
  }
}
